class ShopsController < ApplicationController
  def index
    @shops = Shop.osales.page(params[:page])
    @title = "所有分类 - "
  end

  def show
    @shop = Shop.find(params[:id])
    @title = "#{@shop.name} - #{@shop.category.try :name} -"
    @desc = @shop.meta_desc
  end

  def category
    @category = Category.find(params[:id])
    @shops = @category.shops.osales.page(params[:page])
    @title = "#{@category.name} - "
  end

  def tag
    @name = params[:name]
    @shops = Shop.tagged_with(@name).osales.page(params[:page])
    @title = "#{@name} - "
  end

  def search
    @shops = [] and return if params[:q].blank?
    @shops = Shop.where("name like ?", "%#{params[:q]}%").page(params[:page])
    @title = "搜索 - "
  end
end
